/**
 * 
 */
package com.sci.web.action.systemmanage;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.action.util.PermissionUtil;
import com.sci.web.bean.Permission;
import com.sci.web.dao.SystemManageDao;

/**
 * @author  BaiFuyou
 * @date: Nov 17, 2011 1:40:34 PM
 * 
 * 删除一条权限
 */
public class DeleteRolePermissionByRoleIdAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 9201452597089886995L;
	private int treeid;
	private String datajson;
	@Resource
	private SystemManageDao systemManageDao;
	/**
	 * @return the treeid
	 */
	public int getTreeid() {
		return treeid;
	}
	/**
	 * @param treeid the treeid to set
	 */
	public void setTreeid(int treeid) {
		this.treeid = treeid;
	}
	/**
	 * @return the datajson
	 */
	public String getDatajson() {
		return datajson;
	}
	/**
	 * @param datajson the datajson to set
	 */
	public void setDatajson(String datajson) {
		this.datajson = datajson;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		Permission p = systemManageDao.getPermission(treeid);
		Permission pp = PermissionUtil.getDeleteOnePermission(datajson, p);
		if(systemManageDao.deleteOnePermission_update(pp)){
			super.outPrint("ok");
		}else{
			super.outPrint("fail");
		}
		return "json";
	}

}
